package WeekMatch;

import java.util.Comparator;
import java.util.HashMap;
import java.util.PriorityQueue;

public class P3318 {

}

class P3318Test01{
    public int[] findXSum(int[] nums, int k, int x) {
        int len= nums.length;
        int[] ans=new int[len-k+1];
        HashMap<Integer,Integer> map;
        PriorityQueue<HashMap<Integer,Integer>> queue=new PriorityQueue<>(new ValueComparator());
        for(int i=0;i<len-k+1;i++){
            int n=x;
            map=new HashMap<>();
            for (int j=i;j<k+i;j++){
                if(map.containsKey(nums[j])){
                    map.merge(nums[j],1,Integer::sum);
                }else{
                    map.put(nums[j],1);
                }
            }
            queue.add(map);

            while(n>0){
                queue.poll();

                n--;
            }
        }
        return new int[10];
    }

}
class ValueComparator implements Comparator<HashMap<Integer, Integer>> {
    @Override
    public int compare(HashMap<Integer, Integer> o1, HashMap<Integer, Integer> o2) {
        Integer value1 = o1.values().iterator().next();
        Integer value2 = o2.values().iterator().next();
        return value2.compareTo(value1);
    }
}